<?
	require_once("required/external_module.php");
		
		
	if(empty($title))
	{
		$title="Welcome";
	}
	if(empty($_SESSION['pid']))
	{
		$_SESSION['pid']=1;
	}
	
	//set_error_handler("errRedirect",E_ALL);
	$include_extra="";
	$loginmsg="";
	$mainpage="<a href='index.php'>Home</a>";
		
		
	if(isset($_POST['loginsubmit']))
	{
		$email=$_POST['login_email'];
		$password=$_POST['login_password'];
		$chklogin=mysql_query("select * from os_member where email='$email' and password='$password'");
		//$cururl=$_POST['cururl'];
		
		
		if(mysql_num_rows($chklogin)>0)
		{
			/*
			if(mysql_result($chklogin,0,'status')!='activated')
			{
				$pos = strpos($_SESSION['fullurl'], '?');
				if ($pos == true) 
				{
					$_SESSION['fullurl'].="&errormsg=2&username=$loginname";
				}
				else
				{
					$_SESSION['fullurl'].="?errormsg=2&username=$loginname";
				}
				header("Location:".$_SESSION['fullurl']);
			}
			else
			{
			*/		
				$_SESSION['email']=mysql_result($chklogin,0,'email');
				$_SESSION['loginname']=mysql_result($chklogin,0,'name');
				$_SESSION['member_status']=mysql_result($chklogin,0,'status');
				$_SESSION['member_type']=mysql_result($chklogin,0,'member_type');
				$_SESSION['loginid']=mysql_result($chklogin,0,'id');
				$_SESSION['member_email']=mysql_result($chklogin,0,'email');
				$update=mysql_query("update os_member set total_login=total_login+1 where id=".mysql_result($chklogin,0,'id'));
				
				if(empty($_POST['fromBill']))
				{
		?>
			<script language="javascript">
				window.location="index.php";
			</script>
		<? 
				}
				else
				{
		?>
			<script language="javascript">
				window.location="os_bill.php";
			</script>
		<? 	
			
				}
		}
		elseif(mysql_num_rows($chklogin)==0)
		{
			if(empty($_POST['fromBill'])){
		?>
			<script language="javascript">
				window.location="os_login.php?errormsg=1";
			</script>
		<? 
			}else{
		?>
			<script language="javascript">
				window.location="os_bill.php?errormsg=1";
			</script>
		<? 	
			
			}
			
		}
		else
		{
			echo "unknown error!!";
		}
	}
	
	if(empty($_SESSION['loginid']))
	{
		$member_id=0;
	} 
	else
	{
		$member_id=$_SESSION['loginid'];
		$update_status=mysql_query("update os_member set last_online=now() where id=".$_SESSION['loginid'])or die(mysql_error());		
	}
	
	if(empty($_SESSION['cart']))
	{
		$header_total_items=0;
		$header_total_amount=0;
	}
	else
	{
		$header_total_amount=$_SESSION['total_overall_price'];
		$header_total_items=$_SESSION['total_items'];
	}
	
	if(isset($_POST['changeCurrency']))
	{
		$id=$_POST['changeCurrency'];
		$get_maincurrency=mysql_query("select * from os_currency where id=$id");
		$_SESSION['currency_code']=mysql_result($get_maincurrency,0,"currency_code");
		$_SESSION['currency_rate']=mysql_result($get_maincurrency,0,"rate"); 
		$_SESSION['currency_id']=mysql_result($get_maincurrency,0,"id");
		header("Location:index.php");
	}
	
	if(empty($_SESSION['currency_id']))
	{
		$get_maincurrency=mysql_query("select * from os_currency where is_main=1");
		$_SESSION['currency_code']=mysql_result($get_maincurrency,0,"currency_code");
		$_SESSION['currency_rate']=mysql_result($get_maincurrency,0,"rate"); 
		$_SESSION['currency_id']=mysql_result($get_maincurrency,0,"id");
	}
	
	$btn_home="out";
	$btn_aboutus="out";
	$btn_aquatic="out";
	$btn_agriculture="out";
	$btn_cosmetics="out";
	$btn_distribution="out";
	$btn_contactus="out";
		
	
	switch($_SESSION['pid']){
		
		case "home":
			$btn_home="over";
			break;
		case "aboutus":
			$btn_aboutus="over";
			break;
		case "Aquatic":
			$btn_aquatic="over";
			break;
		case "Agriculture":
			$btn_agriculture="over";
			break;
		case "Cosmetics":
			$btn_cosmetics="over";
			break;	
		case "distribution":
			$btn_distribution="over";
			break;
		case "contactus":
			$btn_contactus="over";
			break;
		
		default:
			$btn_home="out";
			$btn_aboutus="out";
			$btn_aquatic="out";
			$btn_agriculture="out";
			$btn_cosmetics="out";
			$btn_distribution="out";
			$btn_contactus="out";
			break;			
	}
?>

<html>
<head>
<title><?= $title ?> - Psalms Oasis</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="shortcut icon" href="favicon.ico">
<link href="required/style.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<script>
	function removeSearch()
	{
		if(document.searchfrm.keyword.value=="search")
		{
			document.searchfrm.keyword.value="";
		}
	}
	
	
</script>
<script src="required/js/jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="required/js/goAjax.js"></script>
<center>


<table id="Table_01" width="100%" height="467" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td colspan="3">
			<img src="images/header_01.jpg" width="1900" height="183" alt=""></td>
	</tr>
	<tr>
		<td rowspan="2">
			<img src="images/header_02.jpg" width="470" height="123" alt=""></td>
		<td style="background-image:url(images/header_03.jpg);background-repeat:repeat-x;background-position:top" width="451" height="52">
			<table cellpadding="5">
            	<Td><a href="index.php"><font class="top_menu_link">HOME</font></a></Td><td>&nbsp;&nbsp;&nbsp;</td>
                <Td><a href="os_products.php"><font class="top_menu_link">OUR PRODUCTS</font></a></Td><td>&nbsp;&nbsp;&nbsp;</td>
                <Td><a href="os_content.php?type=faq"><font class="top_menu_link">FAQ</font></a></Td><td>&nbsp;&nbsp;&nbsp;</td>
                <Td><a href="os_contact.php"><font class="top_menu_link">CONTACT US</font></a></Td>
                
            </table>
        </td>
		<td rowspan="2">
			<img src="images/header_04.jpg" width="979" height="123" alt=""></td>
	</tr>
	<tr>
		<td>
			<img src="images/header_05.jpg" width="451" height="71" alt=""></td>
	</tr>
	<tr>
		<td colspan="3" style="background-image:url(images/header_06.jpg);background-repeat:repeat-x;background-position:top" width="1900" height="161" bgcolor="#feeb9f">
        	
			<table width="1000" align="center" cellpadding="0" cellspacing="0">
            	<tr>
                	<td colspan="3">
                    	<table width="100%">
                        	 <Td align="left" width="50%">
                            	
                                        <form action="os_search.php" method="post" name="searchfrm">								
                                        <table id="Table_01" width="232" height="28" border="0" cellpadding="0" cellspacing="0" align="left">
                                            <tr>
                                                <td>
                                                    <img src="images/search_01.png" width="15" height="28" alt=""></td>
                                                <td width="190" height="28"  style="background-image:url(images/search_02.jpg)">
                                                    
                                                        <input type="hidden" name="sub_cat" value="">
                                                        <input type="hidden" name="main_cat" value="">
                                                        <input type="hidden" name="price_from" value="">
                                                        <input type="hidden" name="price_to" value="">
                                                        <input type="hidden" name="keyword_type" value="">
                                                        <input type="text" name="keyword" id="keyword" size="30" value="search" onFocus="removeSearch()" maxlength="50" style="border: 0px solid #000000;">                    
                                                </td>
                                                <td>
                                                    <input type="image" alt="submit" src="images/search_03.png" width="27" height="28">
                                                </td>
                                            </tr>
                                        </table>
                                        </form>
                                   
                            </Td>
                        	<Td width="50%">
                            <script>
								function showUpdate()
								{
									changeContent("required/js/ajax_update_cart_info.php","divCartInfo");
									var o=document.getElementById("divCartUpdate");
									var r=o.style;
									r.position='absolute';			
									$('#divCartUpdate').slideDown('slow', function() {
										setTimeout(function(){
										$('#divCartUpdate').slideUp('slow',function(){});
										},3000)
									 });
								
								}
								
								
									
								function doUpdate()
								{
									var pid=document.getElementById("pid").value;
									var item=document.getElementById("item").value;
									var quantity=document.getElementById("quantity").value;
									changeContent("required/js/ajax_update_cart.php?pid="+pid+"&item="+item+"&quantity="+quantity,"divCartUpdate");
									setTimeout("showUpdate()",1000);
								}
								
								
								function showUpdateOnScreen()
								{
									changeContent("required/js/ajax_update_cart_info.php","divCartInfo");
								
								}
								
								function doUpdateOnScreen(id)
								{
									var pid=document.getElementById("pid").value;
									
									var item=document.getElementById("item").value;
									var quantity=document.getElementById("quantity").value;
									showFloatContent("required/js/ajax_update_cart.php?pid="+pid+"&item="+item+"&quantity="+quantity,"divCartUpdate","600","400",0,1);
									
									setTimeout("showUpdateOnScreen()",1000);
								}
								</script>
								<table cellpadding="0" width="100%" align="right" cellspacing="0">
									<td width="100%" align="right" >
										<div id="divCartInfo">
										<img src="images/icons/shopping_cart.png" align="absmiddle">
										<a href="os_mycart.php"><font class="shopping_cart_info"><u>View shopping cart</u></font></a> &nbsp;
										<font class="shopping_cart_info"><?= $header_total_items ?> item(s)</font></a> |
										<font class="shopping_cart_info"><?= $_SESSION['currency_code'] ?> <?= number_format($header_total_amount,2) ?> </font></a>
									   </div>  
									  
									</td>
								
								</table>
                            </Td>
                            
                           
                        </table>
                    </td>
                </tr>
                <Tr>
                	<Td colspan="3">
                    
                    </Td>
                </Tr>
                <tr>
            	<td width="75%" valign="top">